Skip to content

Conversation

@cxzhong
Copy link
Contributor

@cxzhong cxzhong commented Nov 7, 2025

This PR is to allow the platform-specify wheels and preserve the backward compatibility. Then add a package rpds_py as a dependency of jsonschema. and I set when running make dist to make a distribution. it will download all wheels.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

- Introduced a new `tarballs_info` property in the Package class to manage multiple tarballs for platform-specific wheels.
- Implemented `find_tarball_for_platform` method to select the appropriate tarball based on the current platform and Python version.
- Enhanced the `Tarball` class to handle platform-specific wheels, including methods for downloading wheels using pip and checking for cached wheels.
- Updated checksum verification to support multiple tarballs, ensuring integrity checks for downloaded files.
- Added logic to fall back to traditional download methods if pip fails or if no cached wheels are found.
- Created new dependencies and package version files for the `rpds_py` package.
@cxzhong cxzhong closed this Nov 7, 2025
@cxzhong cxzhong reopened this Nov 7, 2025
Remove unused import 'unicode_to_str' from formatter.py
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

Documentation preview for this PR (built with commit 7d67167; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

…h Python version and free-threading status from Sage's Python, and remove pip download logic for platform-specific wheels.
…mproved compatibility checks and streamline the process of finding the best matching tarball for the current platform and Python version.
…aging.utils, improving compatibility with multi-platform wheels.
Updated the download fallback method in tarball.py.
Removed 'text=True' argument from subprocess calls.
@cxzhong cxzhong changed the title TEST: Add rpds_py as a dependency Support Paltform-specify wheels and add rpds_py as a dependency Nov 12, 2025
@cxzhong cxzhong marked this pull request as ready for review November 12, 2025 06:38
@cxzhong cxzhong changed the title Support Paltform-specify wheels and add rpds_py as a dependency Support Plattform-specify wheels and add rpds_py as a dependency Nov 12, 2025
@cxzhong cxzhong changed the title Support Plattform-specify wheels and add rpds_py as a dependency Support Platform-specify wheels and add rpds_py as a dependency Nov 12, 2025
Removed steps for making distribution and downloading packages with '--disable-download-from-upstream-url'.
@cxzhong cxzhong requested a review from Copilot November 13, 2025 07:48
Copilot finished reviewing on behalf of cxzhong November 13, 2025 07:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for platform-specific wheels in the Sage build system and introduces rpds_py as a new dependency. The implementation allows packages to specify multiple platform-specific wheel files in their checksums.ini, with automatic selection based on the target platform's compatibility tags.

Key Changes:

  • Extended tarball and package handling to support multiple platform-specific wheels per package
  • Added platform detection using packaging.tags and packaging.utils modules via subprocess calls
  • Added rpds_py package with 52 platform-specific wheel entries for Python 3.11-3.14 across multiple platforms

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
build/sage_bootstrap/tarball.py Extended Tarball class to handle multi-tarball packages with new methods _download_multiple_wheels() and _download_single_wheel() for platform-specific wheel downloading
build/sage_bootstrap/package.py Added tarballs_info property and find_tarball_for_platform() method for platform detection; modified _init_checksum() to parse multiple tarball entries
build/pkgs/rpds_py/type New package type file marking rpds_py as a "standard" package
build/pkgs/rpds_py/package-version.txt Version specification for rpds_py 0.28.0
build/pkgs/rpds_py/dependencies Dependencies declaration for rpds_py requiring pip and packaging
build/pkgs/rpds_py/checksums.ini Comprehensive checksums for 52 platform-specific wheels covering Python 3.11-3.14 across Linux, macOS, and Windows
build/pkgs/rpds_py/SPKG.rst Documentation for the new rpds_py package describing its purpose and platform support
build/pkgs/jsonschema/dependencies Updated to add rpds_py as a dependency for jsonschema
build/make/Makefile.in Added SAGE_DOWNLOAD_ALL_WHEELS environment variable for downloading all wheels during dist creation
.github/workflows/release.yml Removed duplicate steps and simplified workflow (though this introduced conditional logic issues)
Comments suppressed due to low confidence (2)

build/sage_bootstrap/tarball.py:19

  • Import of 'sys' is not used.
import sys

build/sage_bootstrap/tarball.py:20

  • Import of 'subprocess' is not used.
import subprocess

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +691 to +698
for i, tarball in enumerate(tarballs):
info = {
'tarball': tarball,
'sha256': sha256s[i] if i < len(sha256s) else None,
'sha1': sha1s[i] if i < len(sha1s) else None,
'upstream_url': upstream_urls[i] if i < len(upstream_urls) else None,
}
self.__tarballs_info.append(info)
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential bug: The code assumes that checksums.ini entries are ordered such that the i-th sha256 corresponds to the i-th tarball. However, if a line in checksums.ini has only a tarball without a corresponding sha256 (or vice versa), the indices will be misaligned. For example:

tarball=file1.whl
tarball=file2.whl
sha256=abc123

Would incorrectly assign sha256=abc123 to tarball=file1.whl (index 0) instead of file2.whl. Consider grouping entries by blank lines or using a state machine to ensure correct pairing of tarball/sha256/sha1/upstream_url entries.

Copilot uses AI. Check for mistakes.
Comment on lines 345 to 347
python_code = 'import packaging.utils, json, sys; _, _, _, tags = packaging.utils.parse_wheel_filename(sys.argv[1]); print(json.dumps([str(t) for t in tags]))'
result = subprocess.run(
[sage_script, '-python', '-c', python_code, tarball],
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Potential security consideration: The code executes subprocess.run() with user-controlled input (tarball variable from checksums.ini). While the tarball filename comes from a trusted source (the package's checksums.ini file), it's passed directly to a subprocess call. Consider validating the tarball filename to ensure it doesn't contain shell metacharacters or path traversal sequences, even though it's from a trusted source.

Copilot uses AI. Check for mistakes.
Comment on lines +306 to +307
except Exception as e:
log.warning(f'Error checking cached file: {e}')
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The broad except Exception handler at line 306 catches all exceptions, including potentially serious ones like KeyboardInterrupt (though technically it's BaseException). It would be better to catch specific exceptions like (IOError, ValueError, ChecksumError) to avoid masking unexpected errors. The same issue exists at line 358.

Copilot uses AI. Check for mistakes.
@cxzhong cxzhong marked this pull request as draft November 13, 2025 08:27
@cxzhong cxzhong marked this pull request as ready for review November 14, 2025 05:13
@cxzhong cxzhong requested a review from orlitzky November 14, 2025 07:20
@cxzhong
Copy link
Contributor Author

cxzhong commented Nov 14, 2025

TODO: I will delete python 3.11 packages and 3.13t packages

@orlitzky
Copy link
Contributor

I think this is the right approach, but I happen to be on a platform (riscv/musl) where binary wheels don't exist.

One thing I noticed though is that the new package can be disabled when --disable-notebook is passed to ./configure. There is a long list of packages in configure.ac that get disabled when the notebook is disabled. That should allow people on niche platforms to continue to build sage so long as they disable the notebook.

@cxzhong
Copy link
Contributor Author

cxzhong commented Nov 14, 2025

I think this is the right approach, but I happen to be on a platform (riscv/musl) where binary wheels don't exist.

One thing I noticed though is that the new package can be disabled when --disable-notebook is passed to ./configure. There is a long list of packages in configure.ac that get disabled when the notebook is disabled. That should allow people on niche platforms to continue to build sage so long as they disable the notebook.

yes, I will fix this. I think I can report to upstream to make wheel for some specify platform. Otherwise you have to have a rust toolchain.

@cxzhong
Copy link
Contributor Author

cxzhong commented Nov 16, 2025

I think this is the right approach, but I happen to be on a platform (riscv/musl) where binary wheels don't exist.

One thing I noticed though is that the new package can be disabled when --disable-notebook is passed to ./configure. There is a long list of packages in configure.ac that get disabled when the notebook is disabled. That should allow people on niche platforms to continue to build sage so long as they disable the notebook.

Do you think this way is better or we just remove the notebook dependencies from sage-distro is better?( But some notebook dependencies are also dependencies for building documents, like juypter-sphinx)

@cxzhong
Copy link
Contributor Author

cxzhong commented Nov 16, 2025

I think this is the right approach, but I happen to be on a platform (riscv/musl) where binary wheels don't exist.

One thing I noticed though is that the new package can be disabled when --disable-notebook is passed to ./configure. There is a long list of packages in configure.ac that get disabled when the notebook is disabled. That should allow people on niche platforms to continue to build sage so long as they disable the notebook.

I have done it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants